home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / LANGUAGE.DOC < prev    next >
Text File  |  1992-02-26  |  17KB  |  419 lines

  1.    Copyright (C) 1989, 1990, 1991 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.
  19.  
  20. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  21.  
  22. This file, language.doc, describes the Ghostscript language.
  23.  
  24. For an overview of Ghostscript and a list of the documentation files, see
  25. README.
  26.  
  27. The Ghostscript interpreter, except as noted below, is intended to execute
  28. properly any source program written in a language defined by reference to
  29. the December 1990 printing of the PostScript Language Reference Manual
  30. (Second Edition) published by Addison-Wesley (ISBN 0-201-18127-4).  The
  31. Ghostscript language includes the following elements of the PostScript
  32. (TM) language:
  33.  
  34.     - The full PostScript Level 1 language, as also defined in the
  35. first edition of the PostScript Language Reference Manual, ISBN
  36. 0-201-10174-2, Addison-Wesley, 1985.
  37.  
  38.     - The CMYK color, file system, version 25.0 language, and
  39. miscellaneous additions listed in sections A.1.4, A.1.6, A.1.7, and A.1.8
  40. of the Second Edition respectively.
  41.  
  42.     - The Display PostScript extensions listed in section A.1.3 of the
  43. Second Edition, but excluding the operators listed in section A.1.2, and
  44. also excluding setbbox, xshow, xyshow, and yshow.  These extensions are
  45. only available if the dps feature was selected at the time that
  46. Ghostscript was compiled and linked.
  47.  
  48.     - A few other PostScript Level 2 operators, listed below.
  49.  
  50. Ghostscript also includes a number of operators defined below that are not
  51. in the PostScript language.
  52.  
  53. Stub facilities
  54. ---------------
  55.  
  56. The following operators, while provided in the current release, have only
  57. a partial or dummy implementation.
  58.  
  59. Character and font operators:
  60.     cshow, rootfont, setcachedevice2
  61.  
  62. Graphics state operators:
  63.     currentblackgeneration, currentcmykcolor, currentcolorscreen,
  64.     currentcolortransfer, currenthalftonephase, currentundercolorremoval,
  65.     setblackgeneration, setcmykcolor, setcolorscreen,
  66.     setcolortransfer, sethalftonephase, setundercolorremoval,
  67.     currenthalftone, sethalftone,
  68.     currentstrokeadjust, setstrokeadjust,
  69.     setbbox
  70.  
  71. Interpreter parameter operators:
  72.     setucacheparams, ucachestatus
  73.  
  74. Path construction operators:
  75.     ucache
  76.  
  77. Virtual memory operators:
  78.     currentshared, scheck, setshared, setvmthreshold, shareddict,
  79.     SharedFontDirectory, vmreclaim
  80.  
  81. Level 2 operators
  82. -----------------
  83.  
  84. The following PostScript Level 2 operators are available in Ghostscript:
  85.  
  86.        filter (not all filters are implemented, and most of the
  87.       implemented ones are only available if the filter feature was
  88.       selected when Ghostscript was built)
  89.  
  90. Ghostscript-specific additions
  91. ==============================
  92.  
  93. Miscellaneous
  94. -------------
  95.  
  96. ^Z is counted as whitespace.
  97.  
  98. run can take either a string or a file as its argument.  In the former
  99. case, it uses findlibfile to open the file (searching directories as
  100. needed).  In the latter case, it just runs the file, closing it at the
  101. end, and trapping errors just as for the string case.
  102.  
  103. copy works on devices, as well as on the standard PostScript types.
  104.  
  105. Mathematical operators
  106. ----------------------
  107.  
  108.     <number> arccos <number>
  109.         Computes the arc cosine of a number between -1 and 1.
  110.  
  111.     <number> arcsin <number>
  112.         Computes the arc sine of a number between -1 and 1.
  113.  
  114. Dictionary operators
  115. --------------------
  116.  
  117.     <dict> <integer> setmaxlength -
  118.         Changes the capacity of a dictionary, preserving its
  119.           contents.  Causes a dictfull error if the requested
  120.           capacity is less than the current number of occupied
  121.           entries.
  122.  
  123. String operators
  124. ----------------
  125.  
  126.     <string|name|other> <patternString> stringmatch <boolean>
  127.         Determines whether the string or name matches the given
  128.           pattern.  In the pattern, `*' matches any substring of
  129.           the string, `?' matches any single character, and `\'
  130.           quotes the next character.  If the first argument is not
  131.           a string or name, stringmatch returns true if
  132.           patternString is a single *, and false otherwise.
  133.  
  134.     <state> <fromString> <toString> type1encrypt <newState> <toSubstring>
  135.         Encrypts fromString according to the algorithm for Adobe
  136.           Type 1 fonts, writing the result into toString.
  137.           toString must be at least as long as fromString or a
  138.           rangecheck error occurs.  state is the initial state of
  139.           the encryption algorithm (a 16-bit non-negative
  140.           integer); newState is the new state of the algorithm.
  141.  
  142.     <state> <fromString> <toString> type1decrypt <newState> <toSubstring>
  143.         Decrypts fromString according to the algorithm for Adobe
  144.           Type 1 fonts, writing the result into toString.  Other
  145.           specifications are as for type1encrypt.
  146.  
  147. Relational operators
  148. --------------------
  149.  
  150.     <number|string> <number|string> max <number|string>
  151.         Returns the larger of two numbers or strings.
  152.  
  153.     <number|string> <number|string> min <number|string>
  154.         Returns the smaller of two numbers or strings.
  155.  
  156. File operators
  157. --------------
  158.  
  159.     <string> findlibfile <foundstring> <file> true or <string> false
  160.         Opens the file of the given name for reading.  If the file
  161.           cannot be opened using the supplied name, searches
  162.           through directories as described in use.doc.  If the
  163.           search fails, findlibfile simply pushes false on the
  164.           stack and returns, rather than causing an error.
  165.  
  166.     <file> <integer> unread -
  167.          Pushes back the given character onto the front of the
  168.           file.  If the file is only open for writing, or if the
  169.           C library call (ungetc) fails, causes an ioerror error.
  170.           If the integer is not in the range [0..255], causes
  171.           a rangecheck error.
  172.  
  173.     <file> <device> writeppmfile -
  174.         Writes the contents of the device, which must be an image
  175.           device, onto the file, in Portable PixMap (ppm) format.
  176.           Does not close the file.
  177.  
  178. Path operators
  179. --------------
  180.  
  181.     <x> <y> <width> <height> rectappend -
  182.     <numarray> rectappend -
  183.     <numstring> rectappend -
  184.         Appends a rectangle or rectangles to the current path, in
  185.           the same manner as rectfill, rectclip, etc.  Only
  186.           defined if the dps option is selected.
  187.  
  188. Filters
  189. -------
  190.  
  191. Ghostscript supports only the filters listed below.  Ghostscript does not
  192. support the use of a procedure as a data source or sink, only a file or a
  193. string.  The eexecDecode filter is specific to Ghostscript.
  194.  
  195. The LZW filters are not provided, even though they have been implemented,
  196. because IBM and Unisys both claim a legal monopoly right (patent) to
  197. prevent anyone else from distributing any implementation of the (freely
  198. available) specification of these algorithms.  For more information about
  199. the damaging effects of software patents, contact the League for
  200. Programming Freedom, Cambridge, Massachusetts, U.S.A.
  201.  
  202.     <file|string> /ASCII85Encode filter <file>
  203.         Creates a filter that converts each group of 4 bytes to 5
  204.           printable characters.  Closing the filter writes a '~>'
  205.           on the underlying file.
  206.  
  207.     <file|string> /ASCII85Decode filter <file>
  208.         Creates a filter that reverses the action of
  209.           ASCII85Encode.
  210.  
  211.     <file|string> /ASCIIHexEncode filter <file>
  212.         Creates a filter that converts each byte to two hex
  213.           digits.  Closing the filter writes a '>' on the
  214.           underlying file.
  215.  
  216.     <file|string> /ASCIIHexDecode filter <file>
  217.         Creates a filter that reverses the action of
  218.           ASCIIHexEncode.
  219.  
  220.     <file|string> <seed_integer> /eexecDecode filter <file>
  221.         Creates a filter for decrypting data that has been
  222.           encrypted using eexec encryption as described in the
  223.           Adobe Type 1 Font Format documentation.  The
  224.           seed_integer must be 55665 for proper operation.
  225.  
  226.     <file|string> /NullEncode filter <file>
  227.         Creates a filter that does no transformations.  Only
  228.           useful for creating a "file" that writes to a string.
  229.  
  230.     <file|string> /PFBDecode filter <file>
  231.         Creates a filter that decodes data in .PFB format, the
  232.           usual semi-binary representation for Type 1 font files
  233.           on IBM PC and compatible systems.
  234.  
  235.     <file|string> 0 () /SubFileDecode filter <file>
  236.         Creates a filter that does no transformations.  Only
  237.           useful for creating a "file" that reads from a string.
  238.           (This is the null subcase of the general SubFileDecode
  239.           filter, which Ghostscript does not yet support.)
  240.  
  241. Miscellaneous operators
  242. -----------------------
  243.  
  244.     - currenttime <number>
  245.         Returns the current value of a continuously-running timer,
  246.           in minutes.  The initial value of this timer is undefined.
  247.  
  248.     <string> getenv   <string> true  or  false
  249.         Looks up a name in the shell environment.  If the name is
  250.           found, returns the corresponding value and true; if the
  251.           name is not found, returns false.
  252.  
  253.     <name> <array> makeoperator <operator>
  254.         Constructs and returns a new operator that is actually the
  255.           given procedure in disguise.  The name is only used for
  256.           printing.  The operator has the executable attribute.
  257.  
  258.     <string> <boolean> setdebug -
  259.         If the Ghostscript interpreter was built with the DEBUG
  260.           flag set, sets or resets any subset of the debugging
  261.           flags normally controlled by -Z in the command line.
  262.           Has no effect otherwise.
  263.  
  264. Device operators
  265. ----------------
  266.  
  267.     <index> getdevice <device>
  268.         Returns a device from the set of devices known to the
  269.           system.  The first device, which is default, is numbered
  270.           0.  If the index is out of range, causes a rangecheck
  271.           error.
  272.  
  273.     <matrix> <width> <height> <palette> makeimagedevice <device>
  274.         Makes a new device that accumulates an image in memory.
  275.           matrix is the initial transformation matrix: it must be
  276.           orthogonal (i.e., [a 0 0 b x y] or [0 a b 0 x y]).
  277.           palette is a string of 2^N or 3*2^N elements, specifying
  278.           how the 2^N possible pixel values will be interpreted.
  279.           Each element is interpreted as a gray value, or as RGB
  280.           values, multiplied by 255.  For example, if you want
  281.           a monochrome image for which 0=white and 1=black, the
  282.           palette should be <ff 00>; if you want a 3-bit deep
  283.           image with just the primary colors and their complements
  284.           (ignoring the fact that 3-bit images are not supported),
  285.           the palette might be <000000 0000ff 00ff00 00ffff
  286.           ff0000 ff00ff ffff00 ffffff>.  At present,
  287.           the palette must contain exactly 2 or 256 entries,
  288.           and must contain an entry for black and an entry
  289.           for white; if it contains any entries that aren't black,
  290.           white, or gray, it must contain at least the six primary
  291.           colors (red, green, blue, and their complements cyan,
  292.           magenta, and yellow); aside from this, its contents are
  293.           arbitrary.  (4-entry or 16-entry palettes, corresponding
  294.           to 2- or 4-bit pixels, may be supported eventually.)
  295.         Alternatively, palette can be null.  This is interpreted
  296.           as 32-bit-per-pixel color, where the four bytes of each
  297.           pixel are respectively unused, R, G, and B.
  298.         Note that one can also make an image device (with the same
  299.           palette as an existing image device) by copying a device
  300.           using the copy operator.
  301.  
  302.     <device> <index> <string> copyscanlines <substring>
  303.         Copies one or more scan lines from an image device into a
  304.           string, starting at a given scan line in the image.
  305.           The data is in the same format as for the image
  306.           operator.  Error if the device is not an image device or
  307.           if the string is too small to hold at least one complete
  308.           scan line.  Always copies an integral number of scan
  309.           lines.
  310.  
  311.     <device> setdevice -
  312.         Sets the current device to the specified device.  Also
  313.           resets the transformation and clipping path to the
  314.           initial values for the device.
  315.  
  316.     - currentdevice <device>
  317.         Gets the current device from the graphics state.
  318.  
  319.     <device> devicename <string>
  320.         Gets the name of a device.
  321.  
  322.     <device> <matrix> deviceinitialmatrix <matrix>
  323.         Gets the initial matrix of a device, i.e., the one that
  324.           defaultmatrix would return if the device were the
  325.           current device.
  326.  
  327.     <device> getdeviceprops <mark> <name1> <value1> ... <namen> <valuen>
  328.         Gets all the properties of a device.  Currently defined
  329.           names and values for all devices are:
  330.             Name <string>
  331.                 device name
  332.             HWResolution [<float> <float>]
  333.                 X and Y resolution in pixels/inch
  334.             HWSize [<integer> <integer>]
  335.                 X and Y size in pixels
  336.             InitialMatrix [<6 floats>]
  337.                 initial transformation matrix
  338.         For printers, the following are also defined:
  339.             MaxBitmap <integer>
  340.                 maximum space for a full bitmap in RAM
  341.             BufferSpace <integer>
  342.                 buffer space for band lists, if the bitmap
  343.                   is too big to fit in RAM
  344.             OutputFile <string>
  345.                 () means send to printer directly,
  346.                   otherwise specifies the file name for
  347.                   output; a * is replaced by the page #;
  348.                   on Unix systems, (|command) writes to a pipe
  349.  
  350.     <mark> <name1> <value1> ... <namen> <valuen> <device>
  351.         putdeviceprops <device>
  352.         Sets properties of a device.  May cause undefined,
  353.           typecheck, rangecheck, or limitcheck errors.
  354.  
  355.     - flushpage -
  356.         On displays, flushes any buffered output, so that it
  357.           is guaranteed to show up on the screen; on printers,
  358.           has no effect.
  359.  
  360. Character operators
  361. -------------------
  362.  
  363.     <string> type1addpath -
  364.         Adds the description of a character to the current path,
  365.           and then optionally renders the character.  The string
  366.           argument is a scalable description encoded in Adobe Type
  367.           1 format.  This operator is only valid in the context of
  368.           a show operator, like setcharwidth and setcachedevice.
  369.           It uses information from the current font, in addition
  370.           to the argument.
  371.  
  372.     <image> <width> <height> <wx> <wy> <ox> <oy> <string>
  373.       type1imagepath <substring>
  374.         Converts an image (bitmap) description of a character into
  375.           a scalable description in Adobe Type 1 format.  The
  376.           current transformation matrix should be the same as the
  377.           FontMatrix of the font in which this character will be
  378.           used: this establishes the scaling relationship between
  379.           image pixels (the image is assumed to be 1 unit high in
  380.           user space) and the character coordinate system used in
  381.           the scalable description.  wx and wy are the character
  382.           width, and ox and oy are the character origin relative
  383.           to the lower left corner of the bitmap, in *pixels*.
  384.         All coordinates in the scalable description are rounded to
  385.           integers, so the coefficients in the FontMatrix should
  386.           be on the order of 1/N for some value of N that is
  387.           either a multiple of the height/width or is large
  388.           compared to the width and height.  (There is a
  389.           convention, which some PostScript programs rely on, that
  390.           N=1000.)
  391.         Note that the encoded description has *not* been subjected
  392.           to CharString encryption, which is necessary before the
  393.           description can be given to type1addpath: to do this,
  394.           follow the type1imagepath with
  395.             4330 exch dup type1encrypt exch pop
  396.         If the description is too complex to fit into the supplied
  397.           string, a limitcheck error results.  A good rule of
  398.           thumb is that the size of the string should be about 6
  399.           times the number of 1-bits in the image that are not
  400.           completely surrounded by other 1-bits.
  401.  
  402.     <font> <char> Type1BuildChar -
  403.         This is not a new operator: rather, it is a name known
  404.           specially to the interpreter.  Whenever the interpreter
  405.           needs to render a character (during a ...show,
  406.           stringwidth, or charpath), it looks up the name
  407.           BuildChar in the font dictionary to find a procedure to
  408.           run.  If it does not find this name, and if the FontType
  409.           is 1, the interpreter instead uses the value (looked up
  410.           on the dictionary stack in the usual way) of the name
  411.           Type1BuildChar.
  412.         The standard definition of Type1BuildChar is in gs_fonts.ps.
  413.           Users should not need to redefine Type1BuildChar, except
  414.           perhaps for tracing or debugging.
  415.  
  416. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  417.  
  418. PostScript is a trademark of Adobe Systems, Incorporated.
  419.